﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ADUSWebApp.Models;

namespace ADUSWebApp.Controllers
{
    public class AboutController : Controller
    {
        //
        // GET: /About/
        MoviesEntities db = new MoviesEntities();

        public ActionResult Abouts()
        {
            var about = from a in db.Abouts
                        //select new { a.AboutDate, a.AboutContent,a.AboutRemark};
                        select a;
            return View(about.ToList());
        }

        //
        // GET: /About/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /About/Create

        public ActionResult Create()
        {
            return View("CreateAbout");
        } 

        //
        // POST: /About/Create

        [HttpPost]
        public ActionResult Create(About newabout)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    db.AddToAbouts(newabout);
                    db.SaveChanges();
                    return RedirectToAction("Abouts");
                }
                else
                {
                    return View(newabout);
                }
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /About/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /About/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /About/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /About/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
